package com.example.utils;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class CommonExceptionHandler {
    @ExceptionHandler(AMSException.class)
    public ExceptionResult handlerException(AMSException e){
        return new ExceptionResult(e.getExceptionEnum());
    }
    @ExceptionHandler(Exception.class)
    public ExceptionResult handlerException2(Exception exception){
        return new ExceptionResult(500,exception.getMessage(),null);
    }
}
